#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 2e5 + 10;
ll a[N];
void solve()
{
    ll n;
    cin >> n;
    ll ans = 0;
    ll l, r=0;
    for (ll i = 1; i <= n;i++)
    {
        ll x;
        cin >> x;
        l=x;
        if(l!=r)
        {
            ans++;
            r = l;
        }
    }
    cout << ans << endl;
}
int main()
{
    ll t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}